<template>
    <div class="wrapper">
            <h2>提示框组件</h2>
            <div class="shape">
                <h3>效果展示</h3>
                <div class=show>
                    <Alert class="alert" theme="yes" v-model:toggle="toggle">提示信息</Alert>
                    <Alert class="alert" theme="no" v-model:toggle="toggle">警告信息</Alert> 
                    <Button class="button" theme="button" @click="toggleShow">查看效果</Button>  
                </div>
            </div>
            
            <div class="markdown-body">
                <pre><code>{{
`<Alert theme="yes" v-model:toggle="toggle">提示信息</Alert>
<Alert theme="no" v-model:toggle="toggle">警告信息</Alert>
<!-- 接受两种主题theme:'yes'或theme="no"，使用toggle控制显示隐藏 -->
`
            }}</code></pre>
            </div>
            <div class="shape">
                <h3 @click="getCode">查看源码</h3>
                <main class="markdown-body" v-show="code">
                    <pre><code>{{
`<template>
    <Alert theme="yes" v-model:toggle="toggle">提示信息</Alert>
    <Alert theme="no" v-model:toggle="toggle">警告信息</Alert>
</template>
<script lang="ts">
    import Alert from '../lib/Alert.vue'
    import {ref} from'vue'
    export default {
        components:{Alert},
        setup(){
            let toggle = ref(false)
            const toggleShow=()=>{
                toggle.value = !toggle.value
            } 
            return {toggle,toggleShow}
        },       
    }
</script>`}}</code></pre>
                </main>
            </div>
        </div> 
</template>


<script lang="ts">
import Alert from '../lib/Alert.vue'
import Button from "../lib/Button.vue"
import {ref} from'vue'
export default {
    components:{Alert,Button},
    setup(){
        const pageCode=ref()
        let toggle = ref(false)
        const toggleShow=()=>{
            toggle.value = !toggle.value
        }
        const code=ref(false)
        const getCode=()=>{
                code.value=!code.value
        } 
        return {
            toggle,
            toggleShow,
            code,
            getCode,
            pageCode,
        }
    },       
}
</script>

<style lang="scss" scoped>
.wrapper{
    max-width:800px;
    h2{
        padding-bottom: 30px;
        border-bottom: 1px solid rgb(212, 208, 208);
    }
    .shape{
        margin:30px 0px;
        >h3{
            margin-bottom: 10px;
        }
        >.show{
            display: flex;
            padding: 50px;
            align-items: center;
            justify-content: center;
            border:1px solid rgb(212, 208, 208);
            .alert{
                margin-right: 10px;
            }
            >button{
                margin-top: 10px;
            }
        }
    }
}
@media(max-width: 500px){
    .wrapper{
        max-width: 380px;
        >.shape{
            >.show{
                flex-direction: column;
                >button{
                   margin-top: 20px;
                }                   

            }
        }
    }
}
</style>